import * as server from "@minecraft/server";
import * as power_property from "./power_property";
import * as native_tools from "./native_tools";
import * as achieve_plan from "./achieve_plan";
export function Vapor(self) {
    native_tools.TrySpawnParticle(self.dimension, 'constant:rune_fusion.vapor', self.getHeadLocation());
    self.extinguishFire(true);
}
;
export function Flame(self) {
    native_tools.TrySpawnParticle(self.dimension, 'constant:rune_fusion.flame', self.getHeadLocation());
    self.setOnFire(self.typeId.length * 2, true);
}
;
export function Spread(self) {
    if (!achieve_plan.ControlEventTrigger.EntityToken('元素反应-蔓延', self, 20))
        return;
    const options = {
        excludeTypes: ["minecraft:item", "minecraft:xp_orb"],
        location: self.location,
        maxDistance: 4,
        closest: 4
    };
    const entitys = self.dimension.getEntities(options);
    const getData = power_property.GetProperty(self);
    const hurtData = power_property.MergeProperty(getData, { self_rune: 'rune_green' });
    native_tools.TrySpawnParticle(self.dimension, 'constant:disperse_rune_green', self.getHeadLocation());
    entitys.forEach(target => achieve_plan.RunePowerAttack.BriefCreate(self, target, false, hurtData));
}
;
export function PolarityWhite(self) {
    const health = self.getComponent('health');
    if (!health)
        return;
    const current = health?.currentValue ?? 0;
    const Clamping = Math.max(10, Math.min((current * 0.15), 3000));
    native_tools.TrySpawnParticle(self.dimension, 'constant:rune_fusion.polarity_white', self.getHeadLocation());
    server.system.run(() => power_property.SetProperty(self, { add_rune: "rune_black" }));
    server.system.runTimeout(() => health?.setCurrentValue(current - Clamping), 2);
    native_tools.TrySpawnParticle(self.dimension, "constant:excite_rune_black", self.location);
}
;
export function PolarityBlack(self) {
    const health = self.getComponent('health');
    if (!health)
        return;
    const current = health?.currentValue ?? 0;
    const original = health?.defaultValue ?? 0;
    const Clamping = Math.max(10, Math.min((original * 0.15), 3000));
    native_tools.TrySpawnParticle(self.dimension, 'constant:rune_fusion.polarity_black', self.getHeadLocation());
    server.system.run(() => power_property.SetProperty(self, { add_rune: "rune_white" }));
    server.system.runTimeout(() => health?.setCurrentValue(current - Clamping), 2);
    native_tools.TrySpawnParticle(self.dimension, "constant:excite_rune_white", self.location);
}
;
